// Copyright (c) 2020 Presto Labs Pte. Ltd.
// Author: donggu

#include "coin2/strategy/order_executor/executor.h"

namespace coin2::strategy::order_executor {
namespace impl {

OrderExecutor::OrderExecutor(
    ExchangeType exchange,
    const std::string& name,
    const std::string& order_symbol,
    const OrderExecutorConfig& config,
    IOrderSubsystem* os)
    : name_(name),
      order_symbol_(order_symbol),
      config_orig_(config),
      config_(config),
      os_(os),
      last_buy_ts_(0),
      last_sell_ts_(0),
      prev_check_ts_(0),
      submit_cnt_(0),
      cancel_cnt_(0) {
  switch (exchange) {
    case ExchangeType::Bitflyer:
      update_pos_with_og_pos_period_ = 0;
      break;
    case ExchangeType::Ftx:
      update_pos_with_og_pos_period_ = 30e9;
      break;
    default:
      update_pos_with_og_pos_period_ = 5e9;
      break;
  }
  use_fill_pos_ = update_pos_with_og_pos_period_ > 0;
  LOG(INFO) << "use_fill_pos: " << use_fill_pos_;
}

}  // namespace impl
}  // namespace coin2::strategy::order_executor
